<template>
  <div>
    <iframe
      class="iframe"
      :src="url"
      :style="iframeStyles"
      frameborder="0">
    </iframe>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import { MessageBox } from "mint-ui";

import utils from '@/libs/utils';
import bottomBack from "../modules/bottomBack";
import {HOST_SCHOOL, HOST_OUT} from '@/config/ip.js';
export default {
  data() {
    return {
      items: [],
      url: ""
    };
  },
  components: {
    bottomBack
  },
  mounted() {
    this.items = this.getChajian;
    let networkType = utils.getNetworkType(this.getNetworkStatus);
    if (networkType === "none") {
      MessageBox.alert("message", "title");
    }
    let baseurl = HOST_SCHOOL;
    if (networkType === "out") {
      baseurl = HOST_OUT;
    }
    let id = parseInt(this.$route.params.id);
    let url = baseurl + this.items[id].path;
    if(this.items[id].cjtype){
      url += '?i=' + this.getUserInfo.i;
    }
    this.url = url;
  },
  computed: {
    iframeStyles() {
      return {
        height: window.innerHeight - 80 + "px"
      };
    },
    ...mapGetters([
      "getNetworkStatus",
      "getChajian",
      "getUserInfo"
    ])
  }
};
</script>

<style scoped>
.iframe {
  width: 100%;
}
</style>
